{namespace vh=In2code\Powermail\ViewHelpers}
<f:layout name="Default" />

	Render Powermail_Frontend Edit View
	{mail}                  Mail Object
	{selectedFields}        Selected Fields


<f:section name="main">
	<f:flashMessages class="list-unstyled" />

	<div class="panel panel-default">
        <div class="panel-body">
		<f:if condition="{mail}">
			<f:then>
				<f:if condition="{vh:Condition.IsAllowedToEdit(settings:settings, mail:mail)}">

					<f:then>
						<f:form
								action="update"
								name="field"
								object="{mail}"
								enctype="multipart/form-data"
								additionalAttributes="{vh:Validation.EnableParsleyAndAjax(form:mail.form)}"
								class="powermail_form powermail_form_{mail.form.uid} {form.css} {settings.styles.framework.formClasses}">

							<fieldset class="powermail_fieldset">

								<h3 class="hide">{mail.form.title}</h3>
								<f:render partial="Misc/FormError" arguments="{form:mail.form}" />

								<f:for each="{mail.form.pages}" as="page" iteration="pageIteration">
									<legend class="powermail_legend">
										<f:if condition="{pageIteration.isFirst}">{page.title}</f:if>
									</legend>

									<f:for each="{page.fields}" as="field">
										<f:for each="{selectedFields}" as="selectedField">
											<f:if condition="{selectedField} == {field}">
												<f:if condition="{field.advancedFieldType}">
													<f:then>
														<f:render partial="Form/Field/{vh:String.Upper(string:field.type)}" arguments="{_all}" />
													</f:then>
													<f:else>
														<f:render partial="Output/EditHidden" arguments="{_all}" />
													</f:else>
												</f:if>
											</f:if>
										</f:for>
									</f:for>
								</f:for>

								<f:form.hidden
										name="mail[form]"
										value="{mail.form.uid}"
										class="powermail_form_uid" />

                                <div class="col-md-12">
                                    <f:form.submit value="{f:translate(key: 'PowermailFrontendEditSubmit')}" class="powermail_field powermail_submit btn btn-success" />
                                </div>

							</fieldset>
						</f:form>
					</f:then>

					<f:else>
						<p><f:translate key="PowermailFrontendEditFailed">No Mail given</f:translate></p>
					</f:else>
				</f:if>
			</f:then>
			<f:else>
				<p><f:translate key="PowermailFrontendEditNoMail">Wrong Permissions</f:translate></p>
			</f:else>
		</f:if>

        </div>
	</div>
    <f:link.page pageUid="{listPid}" class="powermail_frontend_back btn btn-default">
        <f:translate key="Back" />
    </f:link.page>
</f:section>